package com.jjb.saas.demo.domain.role.model;

import cn.hutool.extra.spring.SpringUtil;
import com.jjb.saas.demo.domain.role.gateway.RoleGateway;
import com.jjb.saas.framework.domain.model.BaseE;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * @author tzh * @date 2022年07月08日 18:46
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class RoleE extends BaseE {

    //角色名称
    private String roleName;
    //角色编码
    private String roleCode;
    //启用禁用
    private String statusEnum;

    //类型
    private String roleTypeEnum;

    //是否内置
    private String insideEnum;

    //权限组ID
    private List<Long> permsGroupIds;
    
    public static RoleE of(){
        RoleE roleE = new RoleE();
        return roleE;
    }

    public static RoleE of(Long id){
        RoleE roleE = new RoleE();
        roleE.setId(id);
        return roleE;
    }
    /**
     *
     * @return
     */
    public Boolean add() {
        RoleGateway roleGateway = SpringUtil.getBean(RoleGateway.class);
        return roleGateway.add(this);
    }

    /**
     * 修改
     * @return
     */
    public Boolean update() {
        RoleGateway roleGateway = SpringUtil.getBean(RoleGateway.class);
        return roleGateway.update(this);
    }

    /**
     * 修改自身
     * @return
     */
    public Boolean updateSelf() {
        RoleGateway roleGateway = SpringUtil.getBean(RoleGateway.class);
        return roleGateway.updateSelf(this);
    }
}
